package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

//@Controller
//@ResponseBody //所有的handler方法都响应Json
@RestController
public class JsonController {

    @RequestMapping("json")
    //@ResponseBody
    public BaseRespVo json(HttpServletRequest request) {
        //暂时通过这种方式可以拿到参数
        String username = request.getParameter("username");
        return new BaseRespVo("json data", "成功", 0);
    }
    //作业：搭建一个SpringMVC应用，查询user表中的前十条user数据，响应对应的Json数据
    //作为BaseRespVo的data响应Json数据
    //获取参数的方法
    //Controller 👉 Service 👉 Mapper
}
